<!DOCTYPE html>
<html>
<head>
    <style>
        body{
            background-size: 100% ;
        }
    </style>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../css/bootstrap.min-lumen.css" rel="stylesheet">
    <link href="../css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="../css/animate.css" rel="stylesheet">
    <link href="../css/style.css?v=4.1.0" rel="stylesheet">
    <link href="../css/plugins/progressbar/mprogress.css" rel="stylesheet"/>
    <link href="../css/plugins/progressbar/style.css" rel="stylesheet"/>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>
<body class="gray-bg" background="../img/2.png">
<div class="middle-box text-center loginscreen  animated fadeInDown" id="loginModel">
    <div>
        <div>
            <!-- <h1 class="logo-name">h</h1> -->
        </div>
        <h3>欢迎使用</h3>
        <input type="hidden" class="form-control" v-model="id"/>
        <div class="form-group">
            <input type="text" class="form-control" placeholder="用户名" required="" v-model="userName"/>
        </div>
        <div class="form-group">
            <input type="password" class="form-control" placeholder="密码" required="" v-model="password"/>
        </div>
        <div class="form-group">
            <div>
                <a>验证码30秒内有效</a>
                <br>
                <input name="code" id="code" placeholder="验证码" type="text" v-model="code"
                       style="width:170px">
                <!-- 验证码 显示 -->
                <img οnclick="javascript:getvCode()" id="verifyimg" style="margin-left: 20px;"/>
            </div>
        </div>
        <div class="form-group">
            <input type="checkbox" value="remember-me" id="rememberMe" v-model="rememberMe"/>
            记住我
            <a @click="register()">注册</a>

        </div>
        <button class="btn btn-primary block full-width m-b" @click="login()">登 录</button>
        <!-- <p class="text-muted text-center"> <a href="login.html#"><small>忘记密码了？</small></a> | <a href="register.html">注册一个新账号</a>
        </p> -->
    </div>
</div>
<!-- 全局js -->
<script src="../js/config/config.js"></script>
<script src="../js/jquery.min.js?v=2.1.4"></script>
<script src="../js/bootstrap.min.js?v=3.3.6"></script>
<script src="../js/vue/vue.min.js"></script>
<script src="../js/util/ajaxFactory.js"></script>
<script src="../js/plugins/layer/layer.min.js"></script>
<script src="../js/plugins/progressbar/mprogress.js"></script>
<script src="../js/plugins/progressbar/init-mprogress.js"></script>
<script src="../js/encrypt/md5.js"></script>
<script>

			var user = localStorage.getItem("user");
			var username = '';
			var password = '';
			var id = '';
			var code = '';
			if (user != null && user != undefined) {
				try {
					user = JSON.parse(user);
					username = user.username;
					password = user.password;
					id = user.id;
                    code = user.code;

				} catch (err) {}
			}

			var loginVue = new Vue({
				el: "#loginModel",
				data: {
                    userName : username,
                    password : password,
                    id : id,
                    code : code,
					rememberMe: ''
				},
                created(){
                    getvCode();
                },
				methods: {
                    changeImg:function(){
                        document.getElementById("img").src="/imgCode?"+new Date().getTime()
                    },
					login: function() {
						var that = this;
						$z.ajaxPost({
							url: basePath + "/login/doLogin",
							data: {
                                userName : that.userName,
                                password : that.password,
                                id : that.id,
                                code : that.code
							},
							success: function(data) {

								$z.dealCommonResult(data, function() {
										/*localStorage.setItem("user", JSON.stringify({
                                            username : that.userName,
                                            password : that.password,
                                            id : data.data.id
										}));*/
                                    window.location.href = "home.html";
								});

                            }
						});
					},
                    register:function() {
                        window.location.href = "register.html";
                    }
				}
			});




            function getvCode() {
                document.getElementById("verifyimg").src = timestamp("http://localhost:8080/sys/login/verifyCode");
            }
            //为url添加时间戳
            function timestamp(url) {
                var getTimestamp = new Date().getTime();
                if (url.indexOf("?") > -1) {
                    url = url + "&timestamp=" + getTimestamp
                } else {
                    url = url + "?timestamp=" + getTimestamp
                }
                return url;
            };
</script>

</body>

</html>


